
let db = require('../utils/DB');//数据库
let to = require('../utils/await-to-js');
let { SUCCESS1, ERROR } = require('../utils/result');//结果
let jwt = require('../utils/jwt');

//删除购物车商品
function deleteModel() {
    return async (req, res) => {
        
        let { id, token } = req.query;//购物车商品id
        let { uid } = jwt.base64ToJson(token.split('.')[1]);//用户id
        console.log(id);
        console.log(uid);

        let [err, data] = await to(db.query(`DELETE FROM shopcar WHERE id=? AND uid=?`, [id, uid]));
        err ? ERROR(res, '购物车数据删除失败', err) : SUCCESS1(res, '删除成功');
    };
}


module.exports = deleteModel;